package org.rescue;

import java.io.IOException;
import java.util.Scanner;
import java.io.FileReader;

public class countString {
	public static void main(String[] args) {
		count (args[0], args[1]);
	}

	public static void count(String filename, String string) 
	{
		int counter = 0;

		try {
		Scanner file = new Scanner(new FileReader(filename));
		while (file.hasNextLine()) {
			if (file.nextLine().contains(string))
				counter++;
		}
		System.out.println(string + " occurred " + counter + " times.");
		// making sure to close
		file.close();
		} catch (IOException e) {
			System.out.println(e);
		}
	}
}	
